package cn.mumzone.pos.presenter;

import cn.mumzone.basic.mvp.AbsPresenter;
import cn.mumzone.basic.net.http.callback.ApiCallBack;
import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.pos.model.source.UserRepository;
import cn.mumzone.pos.presenter.contract.UpdatePwdContract;

/**
 * author:        yupeng
 * created on:    2019/7/13 00:38
 * description:
 */
public class UpdatePwdPresenter extends AbsPresenter<UpdatePwdContract.View, UserRepository> implements UpdatePwdContract.Presenter {

    @Override
    public void updatePwd(String originPwd, String newPwd) {
        mView.showLoadingDialog();
        ApiCallBack<String> callBack = new ApiCallBack<String>() {
            @Override
            public void onSuccess(String s) {
                mView.dismissLoadingDialog();
                mView.showUpdatePwdSuccess();
            }

            @Override
            public void onError(BaseResponse response) {
                mView.dismissLoadingDialog();
                mView.showError(response.getMsg());

            }
        };
        mRepo.updatePwd(originPwd, newPwd, callBack);
        addSubscrebe(callBack);
    }
}
